<?php

use Illuminate\Database\Seeder;
use App\Models\Tag;
use Illuminate\Support\Facades\Storage;
class TagsTableSeeder extends Seeder
{
    public function run()
    {
        $tagdata = json_decode(Storage::get('tags.json'), true);
        $faker = app(Faker\Generator::class);
        $tags = collect($tagdata)->each(function ($tag, $index) use ($faker) {
            $tag['created_at'] = $created_at = $faker->dateTimeBetween($startDate = '-2 years');
            $tag['updated_at'] = $faker->dateTimeBetween($created_at);
        });
        Tag::insert($tags->toArray());
    }

}

